package generateNodes;

import java.util.ArrayList;
import java.util.Random;

import networkInterface.*;

import object.Node;
import util.NodeUtil;
import util.Settings;

public class GenerateRandomNodes extends GenerateNodeBase {

	@Override
	public Node genNodes(ArrayList<Node> nodes, int xSize, int ySize){
		if(r==null)
			r = new Random(Settings.getInstance().getSeed().hashCode());
		
		Node n;
		do{
			n = new Node(Math.abs(r.nextInt()%xSize), Math.abs(r.nextInt()%ySize));
		} while(!NodeUtil.isValidNodeLocation(n, nodes));
		
		if(r.nextInt()%25 == 0){
			//4g tower
			n.addNetworkInterface(new Tower3GInterface(n));
		} else {
			//wifi node
			n.addNetworkInterface(new SimpleSmallWifiInterface(n));
			n.addNetworkInterface(new SimpleSmallWifiInterface(n));
			if(r.nextInt()%2 == 0)
				n.addNetworkInterface(new SimpleSmallWifiInterface(n));
			if(r.nextInt()%2 == 0)
				n.addNetworkInterface(new SimpleMediumWifiInterface(n));
			if(r.nextInt()%10 == 0)
				n.addNetworkInterface(new Phone3GInterface(n));
		}
		nodes.add(n);
		return n;
		
	}

}
